package com.xiawu;

import java.util.ArrayList;
import java.util.List;

public class TestStudent {
    public static void main(String[] args) {
        // 创建五个学生对象
        Student s1 = new Student(1001,"唐僧","男",40,90);
        Student s2 = new Student(1002,"孙悟空","男",520,80);
        Student s3 = new Student(1003,"猪八戒","男",300,45);
        Student s4 = new Student(1004,"沙和尚","男",240,56);
        Student s5 = new Student(1005,"小白龙","男",1000,67);
        // 加入到集合中
        List<Student>  list = new ArrayList<>();
        list.add(s1);
        list.add(s2);
        list.add(s3);
        list.add(s4);
        list.add(s5);

        // 遍历集合，判断是否成绩及格，并计算及格率
        double sum = 0;  // 不及格人数
        for(Student student : list){
           if(student.getScore()<60){
               System.out.println(student.toString());
               sum++;
           }
        }
        double lv = (list.size()-sum)/list.size();
        System.out.println("及格率是："+ lv*100+"%");


    }
}
